package com.weiaibenpao.demo.chislim.presenter;

import com.weiaibenpao.demo.chislim.base.BasePresenter;
import com.weiaibenpao.demo.chislim.bean.FindSportType;
import com.weiaibenpao.demo.chislim.bean.SportOverInfoBean;
import com.weiaibenpao.demo.chislim.retrofit.RetrofitUtils;
import com.weiaibenpao.demo.chislim.retrofit.rx.LoadingTransformer;
import com.weiaibenpao.demo.chislim.retrofit.rx.NetWorkTransformer;
import com.weiaibenpao.demo.chislim.retrofit.rx.SimpleObserver;
import com.weiaibenpao.demo.chislim.view.RunView;

/**
 * Created by wlx on 2018/1/5.
 */

public class RunPresenter extends BasePresenter<RunView> {
    public void postRunData(int userId, int sportType, int sumSportType,
                            String activitySportsStr, String code, String areaAddress, double yudingDistance,
                            String calories,  String identNumber,
                            String heightphoto, String frequencyphoto, String stridephoto, String runspace, String locusphoto, String locusphotoFunny,
                            int position, long totalTime, String totalStep, double totalDistance){
        RetrofitUtils.getAPIService().postSports(userId,sportType,
                sumSportType,activitySportsStr,code,areaAddress,yudingDistance,calories,identNumber, heightphoto, frequencyphoto,stridephoto,
                runspace,locusphoto,locusphotoFunny,position,totalTime,totalStep, totalDistance)
                .compose(new NetWorkTransformer<SportOverInfoBean>())
                .compose(new LoadingTransformer<SportOverInfoBean>(mContext))
                .subscribe(new SimpleObserver<SportOverInfoBean>(mCompositeDisposable) {
                    @Override
                    public void call(SportOverInfoBean sportInfoBean) {
                        getView().onUploadDataSuccess(sportInfoBean);
                    }
                });

    }
    public void getFindSportType(int userId){
        RetrofitUtils.getAPIService().getSportType(userId)
                .compose(new NetWorkTransformer<FindSportType>())
//                .compose(new LoadingTransformer<FindSportType>(mContext))
                .subscribe(new SimpleObserver<FindSportType>(mCompositeDisposable) {
                    @Override
                    public void call(FindSportType findSportType) {
                        getView().requestFindSportSuccess(findSportType);
                    }
                });
    }
}
